﻿///////////////////////////////////////////////////////////////
//                                                           //
// Code from Arcanea Project.                                //
//                                                           //
// Please include this license part to every reproduction    //
//   of code.                                                //
//                                                           //
// This code is under Ms-RL license                          //
//                                                           //
// Please read futher information about the license,         //
//   the project (news and updates) and the                  //
//   contributors on the address :                           //
//     http://www.codeplex.com/Arcanea/                      //
//                                                           //
///////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
// fwk 3.5
////using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace Arcanea.Mediator.XmlClasses
{
    /// <summary>
    /// Packet de définition des types pour les packet binaires
    /// </summary>
    [XmlRoot]
    public class XmlPacket
    {
        private string name;
        /// <summary>
        /// Nom du packet
        /// </summary>
        [XmlElement]
        public string Name { get { return name; } set { name = value; } }

        private string description;
        /// <summary>
        /// Description du packet
        /// </summary>
        [XmlElement]
        public string Description { get { return description; } set { description = value; } }

        private bool chargerEnBase;
        /// <summary>
        /// Doit il etre charghé en base
        /// </summary>
        [XmlElement]
        public bool ChargerEnBase { get { return chargerEnBase; } set { chargerEnBase = value; } }

        private bool estUneTrameReseau;
        /// <summary>
        /// Est-ce une trame réseau ?
        /// </summary>
        [XmlElement]
        public bool EstUneTrameReseau { get { return estUneTrameReseau; } set { estUneTrameReseau = value; } }

        private IList<XmlField> fields;
        /// <summary>
        /// Liste des fields du packet
        /// </summary>
        [XmlArray]
        [XmlArrayItem]
        public IList<XmlField> Fields { get { return fields; } set { fields = value; } }

        public override string ToString()
        {
            return Name +
                (EstUneTrameReseau ? " (R)" : "") + 
                (ChargerEnBase ? " (B)" : "");
        }

    }
}
